//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.eResearch.Subscriber.Wcf
{
    using System.ServiceModel;
    using Microsoft.Research.eResearch.Blackboard.Common;

    /// <summary>
    /// Provides the service implementation of the <see cref="IWcfNotificationMessageService"/>
    /// interface.
    /// </summary>
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class WcfNotificationMessageService : IWcfNotificationMessageService
    {
        /// <summary>
        /// Notifies the subscriber of a new blackboard message.
        /// </summary>
        /// <param name="message">The new blackboard message.</param>
        public void Notify(BlackboardMessage message)
        {
            NotificationMessageReceiverExtension ext = OperationContext.Current.Host.Extensions.Find<NotificationMessageReceiverExtension>();
            ext.Notify(message);
        }
    }
}
